package sqltest;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

public class JDBCUtils_DML {
    public static void main(String[] args) {
        JDBCUtils_DML dml = new JDBCUtils_DML();
        dml.testUpdate();
    }
    public void testUpdate(){
        Connection connection = null;
        PreparedStatement preparedStatement = null;
        String sql = "update table1 set name=?where id=?";
        try {
            connection=JDBCUtils.getConnection();

            preparedStatement = connection.prepareStatement(sql);
            preparedStatement.setString(1,"mom");
            preparedStatement.setInt(2,60);
            preparedStatement.executeUpdate();
//            System.out.println(update>0?"修改成功！":"修改失败！");
        } catch (SQLException e) {
            e.printStackTrace();
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            JDBCUtils.close(null,preparedStatement,connection);
        }


    }
}

